using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace DesktopWidgetApp.Server.Models
{
    /// <summary>
    /// 团队服务接口
    /// 定义团队管理的核心功能
    /// </summary>
    public interface ITeamService
    {
        /// <summary>
        /// 创建新团队
        /// </summary>
        /// <param name="teamName">团队名称</param>
        /// <param name="description">团队描述</param>
        /// <param name="creatorId">创建者ID</param>
        /// <returns>创建结果</returns>
        Task<(bool success, string message, Team team)> CreateTeamAsync(string teamName, string description, Guid creatorId);

        /// <summary>
        /// 获取团队列表
        /// </summary>
        /// <param name="userId">用户ID</param>
        /// <returns>用户所属的团队列表</returns>
        Task<IEnumerable<Team>> GetUserTeamsAsync(Guid userId);

        /// <summary>
        /// 获取团队详情
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <returns>团队详情</returns>
        Task<Team?> GetTeamByIdAsync(Guid teamId);

        /// <summary>
        /// 更新团队信息
        /// </summary>
        /// <param name="team">团队对象</param>
        /// <returns>更新结果</returns>
        Task<(bool success, string message)> UpdateTeamAsync(Team team);

        /// <summary>
        /// 删除团队
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <param name="requestorId">请求者ID</param>
        /// <returns>删除结果</returns>
        Task<(bool success, string message)> DeleteTeamAsync(Guid teamId, Guid requestorId);

        /// <summary>
        /// 添加团队成员
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <param name="userId">用户ID</param>
        /// <param name="role">成员角色</param>
        /// <param name="requestorId">请求者ID</param>
        /// <returns>添加结果</returns>
        Task<(bool success, string message)> AddTeamMemberAsync(Guid teamId, Guid userId, string role, Guid requestorId);

        /// <summary>
        /// 移除团队成员
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <param name="userId">用户ID</param>
        /// <param name="requestorId">请求者ID</param>
        /// <returns>移除结果</returns>
        Task<(bool success, string message)> RemoveTeamMemberAsync(Guid teamId, Guid userId, Guid requestorId);

        /// <summary>
        /// 获取团队成员列表
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <returns>团队成员列表</returns>
        Task<IEnumerable<TeamMember>> GetTeamMembersAsync(Guid teamId);

        /// <summary>
        /// 检查用户是否为团队成员
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <param name="userId">用户ID</param>
        /// <returns>是否为成员</returns>
        Task<bool> IsUserInTeamAsync(Guid teamId, Guid userId);

        /// <summary>
        /// 检查用户在团队中的角色
        /// </summary>
        /// <param name="teamId">团队ID</param>
        /// <param name="userId">用户ID</param>
        /// <returns>角色名称，如果不是团队成员则返回null</returns>
        Task<string?> GetUserRoleInTeamAsync(Guid teamId, Guid userId);
    }
}